version: "3"

services:
  keepalived:
    image: keepalived
    container_name: keepalived
    restart: always
    network_mode: host
    privileged: true
    build:
      context: .
    environment:
      CNF_HASH: "{{ lookup('template', config_file) | striptags | trim | hash('md5') }}" # Trigger container restart if config changed.
    volumes:
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
      - "{{ keepalived_deploy_path }}/scripts:/etc/keepalived/scripts"
      - "{{ keepalived_deploy_path }}/keepalived.conf:/etc/keepalived/keepalived.conf"
    entrypoint:
      - "keepalived"
      - "--dont-fork"
      - "--log-console"